/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sessionbeans;

import entity.Users;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Axel
 */
@Stateless
public class UsersFacade extends AbstractFacade<Users> {
    @PersistenceContext(unitName = "20121106_TwitterM2iPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    
    
    public UsersFacade() {
        super(Users.class);
    }

    /***
     * 
     * @param name
     * @return Users 
     */
    public Users getName(String name){
        Users res = null;
        try{
            res = (Users)em.createQuery("Select u from Users u where u.name = :name").setParameter("name", name).getSingleResult();
        }catch(NoResultException e){
            //meh
        }
        return res;
    }
    
    
}
